



<div class="x-body">
    <form class="layui-form form_single" action="{:url()}" method="post">


        <div class="layui-form-item">
            <label class="layui-form-label">
                名称:
            </label>
            <div class="layui-input-block">
                <input type="text" name="template_name">


            </div>
        </div>


        <input type="hidden" name="id" value="{$id}"/>

        <div class="box-footer">



            <button type="button"  class="layui-btn ladda-button" data-style="slide-up"  onclick="save()">
                确 定
            </button>
            <a class="layui-btn ladda-button" onclick="javascript:cancel();return false;"><i class="fa fa-history"></i> 取 消</a>


        </div>

    </form>
</div>

<script>
    layui.use('laydate', function(){
        layer=layui.layer;
        //执行一个laydate实例
    });
    function save(){
        var template_name=$("[name='template_name']").val();
        var id=$("[name='id']").val();
        $.post("{:url('copy_template')}",{id:id,template_name:template_name},function (d) {
            if(d.code==1){
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);//关闭当
                parent.location.reload();
            }else{
                layer.msg(d.msg);
            }
        })
    }

    function cancel() {

        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当
    }

</script>